package org.databandtech.job.entity;

import java.util.Arrays;

public class SaveDestination {


	public SaveDestination(String type, String conn, String table, String staticFieldValueMap, String[] fieldNames,
			String[] keyField, Boolean isInsertOrUpdate) {
		super();
		this.type = type;
		this.conn = conn;
		this.table = table;
		this.staticFieldValueMap = staticFieldValueMap;
		this.fieldNames = fieldNames;
		this.keyField = keyField;
		this.isInsertOrUpdate = isInsertOrUpdate;
	}
	
	String type;
	String conn;
	String table;
	
	String staticFieldValueMap; //用于保存到字段的map映射，使用job传递过来的静态数据
	String[] fieldNames; //用于保存查询后的业务数据字段
	String[] keyField; //联合主键，用于更新时定位逻辑
	Boolean isInsertOrUpdate; //true：代表要么新增，如果有原有记录则更新； false： 代表仅新增
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getConn() {
		return conn;
	}
	public void setConn(String conn) {
		this.conn = conn;
	}
	public String getTable() {
		return table;
	}
	public void setTable(String table) {
		this.table = table;
	}
	public String getStaticFieldValueMap() {
		return staticFieldValueMap;
	}
	public void setStaticFieldValueMap(String staticFieldValueMap) {
		this.staticFieldValueMap = staticFieldValueMap;
	}
	public String[] getKeyField() {
		return keyField;
	}
	public void setKeyField(String[] keyField) {
		this.keyField = keyField;
	}
	public Boolean getIsInsertOrUpdate() {
		return isInsertOrUpdate;
	}
	public void setIsInsertOrUpdate(Boolean isInsertOrUpdate) {
		this.isInsertOrUpdate = isInsertOrUpdate;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((conn == null) ? 0 : conn.hashCode());
		result = prime * result + Arrays.hashCode(keyField);
		result = prime * result + ((staticFieldValueMap == null) ? 0 : staticFieldValueMap.hashCode());
		result = prime * result + ((table == null) ? 0 : table.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SaveDestination other = (SaveDestination) obj;
		if (conn == null) {
			if (other.conn != null)
				return false;
		} else if (!conn.equals(other.conn))
			return false;
		if (!Arrays.equals(keyField, other.keyField))
			return false;
		if (staticFieldValueMap == null) {
			if (other.staticFieldValueMap != null)
				return false;
		} else if (!staticFieldValueMap.equals(other.staticFieldValueMap))
			return false;
		if (table == null) {
			if (other.table != null)
				return false;
		} else if (!table.equals(other.table))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}

}
